// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 * Creator: yanking
 * Create time: 2022-02-27 10:42
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.LeetCodeT.Greedy;

public class MaxAreaDoublePointer {
    // 使用双指针
    public int maxArea(int[] height) {
        int max = 0;
        int i = 0;
        int j = height.length - 1;
        while (i != j) {
            int l = j - i;
            int h = Math.min(height[i], height[j]);
            max = Math.max(max, h * l);
            if (height[i] < height[j]) {
                ++i;
            } else {
                --j;
            }
        }
        return max;

    }
}
